home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 August: Tool Chest / Apple_Developer_CD_Series_August_1997_Tool_Chest.iso / Sample Code / SetDeskCPatDemo / MoveableModalDialog.c next >
Encoding:
C/C++ Source or Header  |  1997-06-19  |  1.1 KB  |  63 lines  |  [TEXT/CWIE]

  1. #define OLDROUTINELOCATIONS        0
  2. #define OLDROUTINENAMES            0
  3. #define SystemSevenOrLater        1
  4.  
  5. #include "MoveableModalDialog.h"
  6.  
  7. pascal void MoveableModalDialog (ModalFilterUPP mfp, short *itemHit)
  8. {
  9.     EventRecord event;
  10.     DialogRef pop, dummy;
  11.     WindowRef whichWindow;
  12.     short partCode;
  13.     Boolean handledIt = false;
  14.  
  15.     pop = FrontWindow( );
  16.     *itemHit = -1;
  17.  
  18.     do
  19.     {
  20.         WaitNextEvent (everyEvent & ~highLevelEventMask, &event, GetCaretTime( ), nil);
  21.  
  22.         switch (event.what)
  23.         {
  24.             case mouseDown:
  25.  
  26.                 partCode = FindWindow (event.where, &whichWindow);
  27.  
  28.                 if (whichWindow != pop)
  29.                 {
  30.                     if (partCode == inSysWindow)
  31.                         SystemClick (&event,whichWindow);
  32.                     else
  33.                         SysBeep(10);
  34.                     break;
  35.                 }
  36.  
  37.                 if (inDrag == partCode)
  38.                 {
  39.                     Rect dragBounds;
  40.  
  41.  
  42.                     dragBounds = qd.screenBits.bounds;
  43.                     InsetRect (&dragBounds, 4, 4);
  44.                     DragWindow (pop, event.where, &dragBounds);
  45.                     break;
  46.                 }
  47.  
  48.                 // fall thru
  49.  
  50.             default:
  51.  
  52.                 if (mfp)
  53.                     handledIt = CallModalFilterProc (mfp,pop,&event,itemHit);
  54.  
  55.                 if (!handledIt && IsDialogEvent(&event))
  56.                     DialogSelect(&event,&dummy,itemHit);
  57.  
  58.                 break;
  59.         }
  60.     }
  61.     while (*itemHit == -1);
  62. }
  63.